home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / kriegspi / mate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-30  |  940 b   |  55 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: mate.c,v 1.3 87/02/12 13:23:54 schoch Exp $";
  3. #endif
  4.  
  5. /* mate.c */
  6.  
  7. #include "externs.h"
  8.  
  9. mate (pawnattempts, color)
  10.     int pawnattempts;
  11. u_char color;
  12. {
  13.     LIST l, tos, piecemoves ();
  14.     int from, to;
  15.  
  16.     l = piecelocs [color];
  17.     while (l != NIL) {
  18.         from = l->i;
  19.         l = l->n;
  20.         tos = piecemoves (from, FALSE);
  21.         while (tos != NIL) {
  22.             to = tos->i;
  23.             tos = tos->n;
  24.             if (moveintocheck (from, to))
  25.                 continue;
  26.             if (occupant [from] == PAWN
  27.             && from % 10 != to % 10
  28.             && pawnattempts > 3
  29.             && option [ANNOUNCEPAWNS] == TRUE)
  30.                 continue;
  31.             return FALSE;
  32.         }
  33.     }
  34.     return TRUE;
  35. }
  36.  
  37. insufficient ()
  38. {
  39.     int i, p, minorpieces = 0;
  40.     LIST l;
  41.  
  42.     for (i = 0; i < 2; i++) {
  43.         l = piecelocs [i];
  44.         while (l != NIL) {
  45.             p = occupant [l->i];
  46.             if (p == QUEEN || p == ROOK || p == PAWN)
  47.                 return FALSE;
  48.             if (p == KNIGHT || p == BISHOP)
  49.                 minorpieces++;
  50.             l = l->n;
  51.         }
  52.     }
  53.     return (minorpieces <= 2);
  54. }
  55.